<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>[Generic Component Framework v3] GCF::Result Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<!--link href="tabs.css" rel="stylesheet" type="text/css"-->
</head><body>
 <div id="wrapper">
    <div id="logo_box">
        <a class="img_link" href="https://github.com/pnudupa/gcf" target="_blank" ><img style="float:left;margin-left:10px;margin-top:5px;margin-bottom:5px;"src="header_gcf_logo.jpg" alt="GCF LOGO"/></a>
        <a class="img_link" href="https://www.vcreatelogic.com/" target="_blank" ><img style="float:right;margin-right:10px; margin-top: 30px;" src="header_vcl_logo.jpg" alt="VCL LOGO"/></a>
        <div style="clear:both"></div>
    </div>
    <div class="nav">
        <ul>
            <li class="selectedpage">
                <a class="a-home" href="index.html" >
                    <span>Home</span>
                </a>
            </li>
            <li>
                <a class="a-classes " href="classes.html">
                    <span>All Classes</span>
                </a>
            </li>
            <li>
                <a class="a-home " href="gcf_modules.html">
                    <span>Modules</span>
                </a>
            </li>
            <li>
                <a class="a-home " href="gcf_guides_and_videos.html">
                    <span>Guides & Videos</span>
                </a>
            </li>
            <li>
                <a class="a-home " href="gcf_tools_and_inbuilt_components.html">
                    <span>Tools & Components</span>
                </a>
            </li>
        </ul>
    </div>
    <div id="main-content">
        <div class="inside">
        <div>
<!-- Generated by Doxygen 1.8.16 -->
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>GCF</b></li><li class="navelem"><a class="el" href="class_g_c_f_1_1_result.html">Result</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="class_g_c_f_1_1_result-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">GCF::Result Class Reference<div class="ingroups"><a class="el" href="group__gcf__core.html">GCF Core Module</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>This class allows representation of the result of a process and/or function.  
 <a href="class_g_c_f_1_1_result.html#details">More...</a></p>

<p><code>#include &lt;GCF3/GCFGlobal&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ada7077ddcecb5deb742b9eb9e6e2adb2"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#ada7077ddcecb5deb742b9eb9e6e2adb2">Result</a> ()</td></tr>
<tr class="separator:ada7077ddcecb5deb742b9eb9e6e2adb2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a11e9dc8bdd4b4feb3140516e684dd6d2"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#a11e9dc8bdd4b4feb3140516e684dd6d2">Result</a> (bool val)</td></tr>
<tr class="separator:a11e9dc8bdd4b4feb3140516e684dd6d2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a38ec7a50287c49dd5ffdfab40a2bdb4b"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#a38ec7a50287c49dd5ffdfab40a2bdb4b">Result</a> (bool val, const QString &amp;<a class="el" href="class_g_c_f_1_1_result.html#a146925fef5174ad713fefaf147037822">code</a>, const QString &amp;msg=QString(), const QVariant &amp;<a class="el" href="class_g_c_f_1_1_result.html#ac76e6791e114ef677e4c0a867597fb68">data</a>=QVariant())</td></tr>
<tr class="separator:a38ec7a50287c49dd5ffdfab40a2bdb4b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2866446761bc12e19a5502fa473482b8"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#a2866446761bc12e19a5502fa473482b8">Result</a> (const <a class="el" href="class_g_c_f_1_1_result.html">Result</a> &amp;other)</td></tr>
<tr class="separator:a2866446761bc12e19a5502fa473482b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae026676b8d467f5db07d78e1499f7af1"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#ae026676b8d467f5db07d78e1499f7af1">isSuccess</a> () const</td></tr>
<tr class="separator:ae026676b8d467f5db07d78e1499f7af1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a146925fef5174ad713fefaf147037822"><td class="memItemLeft" align="right" valign="top">QString&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#a146925fef5174ad713fefaf147037822">code</a> () const</td></tr>
<tr class="separator:a146925fef5174ad713fefaf147037822"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a09748971d54f1bec086caeec11be2df9"><td class="memItemLeft" align="right" valign="top">QString&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#a09748971d54f1bec086caeec11be2df9">message</a> () const</td></tr>
<tr class="separator:a09748971d54f1bec086caeec11be2df9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac76e6791e114ef677e4c0a867597fb68"><td class="memItemLeft" align="right" valign="top">QVariant&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#ac76e6791e114ef677e4c0a867597fb68">data</a> () const</td></tr>
<tr class="separator:ac76e6791e114ef677e4c0a867597fb68"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adf1a85fc2c859c5dfef1c10d96d137ce"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_g_c_f_1_1_result.html">Result</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#adf1a85fc2c859c5dfef1c10d96d137ce">operator=</a> (const <a class="el" href="class_g_c_f_1_1_result.html">Result</a> &amp;other)</td></tr>
<tr class="separator:adf1a85fc2c859c5dfef1c10d96d137ce"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a90f7d095fd624af16167e7ee4a72fbc6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="class_g_c_f_1_1_result.html">Result</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#a90f7d095fd624af16167e7ee4a72fbc6">operator=</a> (bool val)</td></tr>
<tr class="separator:a90f7d095fd624af16167e7ee4a72fbc6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3bcdcca01de6b43fea10493ad5f2384e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#a3bcdcca01de6b43fea10493ad5f2384e">operator==</a> (const <a class="el" href="class_g_c_f_1_1_result.html">Result</a> &amp;other) const</td></tr>
<tr class="separator:a3bcdcca01de6b43fea10493ad5f2384e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ace29101da54ff2d23ae4f6d1bda0cab7"><td class="memItemLeft" align="right" valign="top">QString&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_g_c_f_1_1_result.html#ace29101da54ff2d23ae4f6d1bda0cab7">toString</a> () const</td></tr>
<tr class="separator:ace29101da54ff2d23ae4f6d1bda0cab7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>This class can be used to capture in one object the following </p><ul>
<li>success/failure flag </li>
<li>error code and error message in case of failure </li>
<li>data in case of success</li>
</ul>
<p>This class can be used as a return data-type in almost any function, specially functions that return true/false. The benefit of using this class in such a function is that you can return a error code+message incase of failure and concrete result in case of success.</p>
<p>Example: </p><div class="fragment"><div class="line"><a class="code" href="class_g_c_f_1_1_result.html">GCF::Result</a> divide(<span class="keyword">const</span> <span class="keywordtype">double</span> a, <span class="keyword">const</span> <span class="keywordtype">double</span> b)</div>
<div class="line">{</div>
<div class="line">    <span class="keywordflow">if</span>(b == 0)</div>
<div class="line">        <span class="keywordflow">return</span> <a class="code" href="class_g_c_f_1_1_result.html">GCF::Result</a>(<span class="keyword">false</span>, <span class="stringliteral">&quot;DIV_BY_ZERO&quot;</span>, <span class="stringliteral">&quot;b is ZERO&quot;</span>);</div>
<div class="line"> </div>
<div class="line">    <span class="keyword">const</span> <span class="keywordtype">double</span> retVal = a/b;</div>
<div class="line">    <span class="keywordflow">return</span> <a class="code" href="class_g_c_f_1_1_result.html">GCF::Result</a>(<span class="keyword">true</span>, QString(), QString(), retVal);</div>
<div class="line">}</div>
</div><!-- fragment --><p>This would allow the caller of your method to get a sense of what went wrong, incase of an error.</p>
<p>Example: </p><div class="fragment"><div class="line"><a class="code" href="class_g_c_f_1_1_result.html">GCF::Result</a> result = ::divide(20, 0);</div>
<div class="line"><span class="keywordflow">if</span>(!result)</div>
<div class="line">    QMessageBox::information(..., <span class="stringliteral">&quot;Error&quot;</span>, result.<a class="code" href="class_g_c_f_1_1_result.html#a09748971d54f1bec086caeec11be2df9">message</a>());</div>
<div class="line"><span class="keywordflow">else</span></div>
<div class="line">    ....</div>
</div><!-- fragment --> </div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="ada7077ddcecb5deb742b9eb9e6e2adb2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ada7077ddcecb5deb742b9eb9e6e2adb2">&#9670;&nbsp;</a></span>Result() <span class="overload">[1/4]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">GCF::Result::Result </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Default constructor. Constructs result with success-flag as false. </p>

</div>
</div>
<a id="a11e9dc8bdd4b4feb3140516e684dd6d2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a11e9dc8bdd4b4feb3140516e684dd6d2">&#9670;&nbsp;</a></span>Result() <span class="overload">[2/4]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">GCF::Result::Result </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>val</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Constructs result with success-flag as <code>val</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">val</td><td>success-flag of the result </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a38ec7a50287c49dd5ffdfab40a2bdb4b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a38ec7a50287c49dd5ffdfab40a2bdb4b">&#9670;&nbsp;</a></span>Result() <span class="overload">[3/4]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">GCF::Result::Result </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>val</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>code</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QString &amp;&#160;</td>
          <td class="paramname"><em>msg</em> = <code>QString()</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const QVariant &amp;&#160;</td>
          <td class="paramname"><em>data</em> = <code>QVariant()</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Constructs a result from the given parameters</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">val</td><td>success-flag of the result </td></tr>
    <tr><td class="paramname">code</td><td>erorr-code of the result </td></tr>
    <tr><td class="paramname">msg</td><td>error-message of the result </td></tr>
    <tr><td class="paramname">data</td><td>data (or result) of the result </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a2866446761bc12e19a5502fa473482b8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2866446761bc12e19a5502fa473482b8">&#9670;&nbsp;</a></span>Result() <span class="overload">[4/4]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">GCF::Result::Result </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_g_c_f_1_1_result.html">Result</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Copy constructor </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ae026676b8d467f5db07d78e1499f7af1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae026676b8d467f5db07d78e1499f7af1">&#9670;&nbsp;</a></span>isSuccess()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool GCF::Result::isSuccess </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>success-flag of the result </dd></dl>

</div>
</div>
<a id="a146925fef5174ad713fefaf147037822"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a146925fef5174ad713fefaf147037822">&#9670;&nbsp;</a></span>code()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">QString GCF::Result::code </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>error code of the result, if <a class="el" href="class_g_c_f_1_1_result.html#ae026676b8d467f5db07d78e1499f7af1">isSuccess()</a> returns false. Empty string otherwise. </dd></dl>

</div>
</div>
<a id="a09748971d54f1bec086caeec11be2df9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a09748971d54f1bec086caeec11be2df9">&#9670;&nbsp;</a></span>message()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">QString GCF::Result::message </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>error message of the result, if <a class="el" href="class_g_c_f_1_1_result.html#ae026676b8d467f5db07d78e1499f7af1">isSuccess()</a> returns false. Empty string otherwise. </dd></dl>

</div>
</div>
<a id="ac76e6791e114ef677e4c0a867597fb68"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac76e6791e114ef677e4c0a867597fb68">&#9670;&nbsp;</a></span>data()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">QVariant GCF::Result::data </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>data of the result, if <a class="el" href="class_g_c_f_1_1_result.html#ae026676b8d467f5db07d78e1499f7af1">isSuccess()</a> return true. Invalid <code>QVariant</code> otherwise. </dd></dl>

</div>
</div>
<a id="adf1a85fc2c859c5dfef1c10d96d137ce"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adf1a85fc2c859c5dfef1c10d96d137ce">&#9670;&nbsp;</a></span>operator=() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_g_c_f_1_1_result.html">GCF::Result</a> &amp; GCF::Result::operator= </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_g_c_f_1_1_result.html">Result</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Assignment operator </p>

</div>
</div>
<a id="a90f7d095fd624af16167e7ee4a72fbc6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a90f7d095fd624af16167e7ee4a72fbc6">&#9670;&nbsp;</a></span>operator=() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_g_c_f_1_1_result.html">GCF::Result</a> &amp; GCF::Result::operator= </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>val</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Assignment operator </p>

</div>
</div>
<a id="a3bcdcca01de6b43fea10493ad5f2384e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3bcdcca01de6b43fea10493ad5f2384e">&#9670;&nbsp;</a></span>operator==()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool GCF::Result::operator== </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_g_c_f_1_1_result.html">Result</a> &amp;&#160;</td>
          <td class="paramname"><em>other</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Comparison operator </p>

</div>
</div>
<a id="ace29101da54ff2d23ae4f6d1bda0cab7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ace29101da54ff2d23ae4f6d1bda0cab7">&#9670;&nbsp;</a></span>toString()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">QString GCF::Result::toString </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>a string representation of the result.</dd></dl>
<dl class="section note"><dt>Note</dt><dd><code>operator&lt;&lt;</code> on <code>QDebug</code> has been overloaded to print into debug output string representations of <a class="el" href="class_g_c_f_1_1_result.html">GCF::Result</a>. So you can stream this object into <code>qDebug()</code>. Example: <div class="fragment"><div class="line"><a class="code" href="class_g_c_f_1_1_result.html">GCF::Result</a> result = ...</div>
<div class="line">qDebug() &lt;&lt; result;</div>
</div><!-- fragment --> </dd></dl>

</div>
</div>
</div><!-- contents -->
<div class="ttc" id="aclass_g_c_f_1_1_result_html"><div class="ttname"><a href="class_g_c_f_1_1_result.html">GCF::Result</a></div><div class="ttdoc">This class allows representation of the result of a process and/or function.</div><div class="ttdef"><b>Definition:</b> GCFGlobal.h:58</div></div>
<div class="ttc" id="aclass_g_c_f_1_1_result_html_a09748971d54f1bec086caeec11be2df9"><div class="ttname"><a href="class_g_c_f_1_1_result.html#a09748971d54f1bec086caeec11be2df9">GCF::Result::message</a></div><div class="ttdeci">QString message() const</div><div class="ttdef"><b>Definition:</b> GCFGlobal.h:75</div></div>
</div>
</div>
</div>
<div class="footer_content">
<table width="100%" class="footer">
<tr>
<td align="left" width="50%">Copyright &copy; 2013-2019,
 <a class="el" href="http://www.vcreatelogic.com" target="_black">VCreate Logic Private Limited</a></td>
<td align="right" width="50%"><a class="el" href="http://www.vcreatelogic.com/products/gcf" target="_black">GCF - Generic Component Framework</a></td>
</tr>
</table>
</div>
</div>
</body>
</html>
